package com.ljm.sys.swagger;

import com.ljm.commom.web.conf.SwaggerConfig;
import com.ljm.common.util.SwaggerUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import javax.annotation.Resource;

/**
 * @author: ChenHuaMing
 * @Date: 2020/5/22 17:53
 * @Description:
 */
@Configuration
public class LjmSwaggerConf {
    @Lazy
    @Resource
    private SwaggerConfig swaggerConfig;

    @Bean
    public Docket defaultAuthApi() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(swaggerConfig.apiInfo())
                //分组名称
                .groupName("权限管理")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.ljm.sys.auth.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean
    public Docket defaultOrgApi() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(swaggerConfig.apiInfo())
                //分组名称
                .groupName("组织管理")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.ljm.sys.org.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    @Bean
    public Docket defaultSysSetApi() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(swaggerConfig.apiInfo())
                //分组名称
                .groupName("系统配置")
                .select()
                //这里指定Controller扫描包路径
                .apis(SwaggerUtil.basePackage("com.ljm.sys.dict.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}
